package wepayu.tests;

import wepayu.utils.Data;
import junit.framework.TestCase;

/**
 * Testes para a classe Data.
 * @author Gustavo de Farias
 * @author Lucas Albertins
 *
 */
public class DataTest extends TestCase {

	/**
	 * Test method for 'wepayu.Data.Data(String)'
	 */
	public void testDataConstrutor() {
		try {
			new Data("1/13/2004");
			fail();
		} catch(Exception e) {}
		try {
			new Data("30/02/2001");
			fail();
		} catch(Exception e) {}
		try {
			new Data("32/1/1990");
			fail();
		} catch(Exception e) {}
		try {
			new Data("1/12/0");
			fail();
		} catch(Exception e) {}
		try {
			new Data("0/4/345");
			fail();
		} catch(Exception e) {}
		
		try {
			new Data("01/01/01");
			new Data("001/003/3004");
			new Data("31/01/2005");
			new Data("1/1/1");
		} catch(Exception e) {
			fail();
		}
	}

	/**
	 * Test method for 'wepayu.Data.compareTo(Data)'
	 */
	public void testCompareTo() {
		Data d1 = new Data("31/01/2005");
		Data d2 = new Data("30/01/2005");
		Data d3 = new Data("31/01/2005");
		Data d4 = new Data("10/02/2000");
		Data d5 = new Data("10/02/2001");
		Data d6 = new Data("10/03/2001");
		
		assertTrue(d1.compareTo(d2) > 0);
		assertTrue(d2.compareTo(d1) < 0);
		assertTrue(d1.compareTo(d1) == 0);
		assertTrue(d2.compareTo(d2) == 0);
		assertTrue(d1.compareTo(d3) == 0);
		assertTrue(d3.compareTo(d1) == 0);
		assertTrue(d4.compareTo(d5) < 0);
		assertTrue(d5.compareTo(d4) > 0);
		assertTrue(d5.compareTo(d6) < 0);
		assertTrue(d6.compareTo(d5) > 0);
		
	}

	/**
	 * Test method for 'wepayu.Data.equals(Data)'
	 */
	public void testEqualsData() {
		Data d1 = new Data("31/01/2005");
		Data d2 = new Data("30/01/2005");
		Data d3 = new Data("31/01/2005");
				
		assertTrue(d1.equals(d3));
		assertTrue(d3.equals(d1));
		assertTrue(d2.equals(d2));
		assertTrue(d3.equals(d3));
		
		assertFalse(d1.equals(d2));
		assertFalse(d2.equals(d1));
	}
}